package net.mcreator.toolsasfood.procedures;

import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Entity;
import net.minecraft.core.BlockPos;

public class NetheritePickaxeProcedure {
	public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
		if (entity == null)
			return;
		double fx = 0;
		double fy = 0;
		double fz = 0;
		double nx = 0;
		double nz = 0;
		fx = entity.getPersistentData().getDouble("fx");
		fy = entity.getPersistentData().getDouble("fy");
		fz = entity.getPersistentData().getDouble("fz");
		if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem()
				.isCorrectToolForDrops((world.getBlockState(new BlockPos((int) x, (int) y, (int) z))))) {
			if (0 == fy) {
				if (!(0 == fx)) {
					fx = 0;
					fz = 1;
				} else {
					fx = 1;
					fz = 0;
				}
				nx = x + fx;
				fy = y - 1;
				nz = z + fz;
				for (int index0 = 0; index0 < (int) (3); index0++) {
					for (int index1 = 0; index1 < (int) (3); index1++) {
						if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem()
								.isCorrectToolForDrops((world.getBlockState(new BlockPos((int) nx, (int) fy, (int) nz))))) {
							world.destroyBlock(new BlockPos((int) nx, (int) fy, (int) nz), false);
							RandomDropsProcedure.execute(world, nx, fy, nz);
						}
						nx = nx - fx;
						nz = nz - fz;
					}
					nx = x + fx;
					nz = z + fz;
					fy = fy + 1;
				}
			} else {
				fx = x + 1;
				fy = y;
				fz = z + 1;
				for (int index2 = 0; index2 < (int) (3); index2++) {
					for (int index3 = 0; index3 < (int) (3); index3++) {
						if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem()
								.isCorrectToolForDrops((world.getBlockState(new BlockPos((int) fx, (int) fy, (int) fz))))) {
							world.destroyBlock(new BlockPos((int) fx, (int) fy, (int) fz), false);
							RandomDropsProcedure.execute(world, fx, fy, fz);
						}
						fx = fx - 1;
					}
					fx = x + 1;
					fz = fz - 1;
				}
			}
		}
		entity.getPersistentData().putBoolean("bkd", (true));
	}
}
